package com.whsxt.config;

import com.whsxt.constant.QueueConstant;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author: caoqingwen
 * @CreateTime: 2021-03-22 21:00
 * @Description:
 */
@Configuration
public class MqSendMsgConfig {


    /**
     * 短信配置
     *
     * @return
     */
    @Bean
    public Queue sendSmsQueue() {
        return new Queue(QueueConstant.PHONE_SEND_QUEUE);
    }

    @Bean
    public DirectExchange sendSmsEx() {
        return new DirectExchange(QueueConstant.PHONE_SEND_EX);
    }


    @Bean
    public Binding smsBinding() {
        return BindingBuilder.bind(sendSmsQueue()).to(sendSmsEx()).with(QueueConstant.PHONE_SEND_KEY);
    }


    /**
     * 微信配置
     *
     * @return
     */
    @Bean
    public Queue wxQueue() {
        return new Queue(QueueConstant.WECHAT_SEND_QUEUE);
    }


    @Bean
    public DirectExchange wxMsgEx() {
        return new DirectExchange(QueueConstant.WECHAT_SEND_EX);
    }

    @Bean
    public Binding wxBinding() {
        return BindingBuilder.bind(wxQueue()).to(wxMsgEx()).with(QueueConstant.WECHAT_SEND_KEY);
    }


}
